package org.budo.canal.instance.spring;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

import com.alibaba.otter.canal.instance.core.CanalInstance;
import com.alibaba.otter.canal.instance.core.CanalInstanceGenerator;

/**
 * @author lmw
 */
public class BudoSpringCanalInstanceGenerator implements CanalInstanceGenerator, BeanFactoryAware {
    private BeanFactory beanFactory;

    public CanalInstance generate(String destination) {
        String beanName = destination;
        return (CanalInstance) beanFactory.getBean(beanName);
    }

    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
    }
}
